﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.UpdateContinuousMfg.CApUCMUpdateContinuousMfgCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.PrivateImplementationDetails;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.UpdateContinuousMfg;

public class CApUCMUpdateContinuousMfgCmd : TxButtonCommand
{
  private CApUCMUpdateContinuousMfgEnabler _enabler;
  private const string _STRING_TABLE_LOCATION = "DnProcessSimulateCommands.UpdateContinuousMFG.UCMStringTable";
  private ResourceManager _resourceManager;
  private TxForm _updateContinuousMfgForm;

  public CApUCMUpdateContinuousMfgCmd()
  {
    this._enabler = new CApUCMUpdateContinuousMfgEnabler();
    this._resourceManager = new ResourceManager("DnProcessSimulateCommands.UpdateContinuousMFG.UCMStringTable", ((object) this).GetType().Assembly);
  }

  public virtual bool Licensed => TxCommandLicenser.UpdateContinuousMfgLicense;

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this._enabler;

  public virtual string Bitmap => this._resourceManager.GetString("UPDATE_CONTINUOUS_MFG_BITMAP");

  public virtual string Category
  {
    get => this._resourceManager.GetString("UPDATE_CONTINUOUS_MFG_CATEGORY");
  }

  public virtual string Description
  {
    get => this._resourceManager.GetString("UPDATE_CONTINUOUS_MFG_DESCRIPTION");
  }

  public virtual string Name => this._resourceManager.GetString("UPDATE_CONTINUOUS_MFG_NAME");

  public virtual string Tooltip => this._resourceManager.GetString("UPDATE_CONTINUOUS_MFG_TOOLTIP");

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("UpdateContinuousMfg");

  public virtual void Execute(object cmdParams)
  {
    if (!this._enabler.Enable || this._updateContinuousMfgForm != null)
      return;
    if (TxTcUtilities.IsTcAnyPlatform)
    {
      TxSeamMfgFeature selectedObject = CApUCMUpdateContinuousMfgEnabler.GetSelectedObject() as TxSeamMfgFeature;
      if (TxSeamMfgFeature.op_Inequality(selectedObject, (ITxObject) null))
        this._updateContinuousMfgForm = !((TxMfgFeature) selectedObject).IsPrivate() ? (TxForm) new CCUiUCMUpdateContinuousMfgExposedTCDlg() : (TxForm) new CCUiUCMUpdateContinuousMfgTCDlg();
    }
    else
      this._updateContinuousMfgForm = (TxForm) new CCUiUCMUpdateContinuousMfgDlg();
    ((Form) this._updateContinuousMfgForm).FormClosed += new FormClosedEventHandler(this._updateContinuousMfgForm_FormClosed);
    TxApplication.ApplicationEvents.Exiting += new TxApplication_ExitingEventHandler(this.ApplicationEvents_Exiting);
    ((Control) this._updateContinuousMfgForm).Show();
  }

  private void _updateContinuousMfgForm_FormClosed(object sender, FormClosedEventArgs e)
  {
    this._updateContinuousMfgForm = (TxForm) null;
    TxApplication.ApplicationEvents.Exiting -= new TxApplication_ExitingEventHandler(this.ApplicationEvents_Exiting);
  }

  private void ApplicationEvents_Exiting(object sender, TxApplication_ExitingEventArgs args)
  {
    if (this._updateContinuousMfgForm == null)
      return;
    ((Form) this._updateContinuousMfgForm).Close();
  }
}
